//
//  TravelAreaButtonView.m
//  ToWhere
//
//  Created by dllo on 15/11/16.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "TravelAreaButtonView.h"

@implementation TravelAreaButtonView
-(void)dealloc
{
    [_labelN release];
    [_iView release];
    [_btn release];
    
    [_imageUrl release];
    [_labelStr release];
    [super dealloc];
    
}

-(instancetype)initWithLabelStr:(NSString *)str ImageUrl:(NSString *)url
{
    self = [super init];
    if (self) {
        
        _labelStr = str;
        _imageUrl = url;
        
        [self createView];
        
    }
    
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.btn.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
   self.iView.frame= CGRectMake(10 *kWidth, 0, self.frame.size.width - 20 *kWidth, self.frame.size.height / 3 * 2);
    self.labelN.frame = CGRectMake(0, self.frame.size.height / 3 * 2, self.frame.size.width, self.frame.size.height / 3);
}
-(void)createView
{
    self.btn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.btn.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
   // self.btn.backgroundColor = [UIColor blackColor];
    
    [self addSubview:self.btn];
    
    self.iView = [[UIImageView alloc]init];
              
    self.iView.image = [UIImage imageNamed:self.imageUrl];
    [self.btn addSubview:self.iView];
    [_iView release];
   
    self.labelN = [[UILabel alloc]init ];
    
    self.labelN.text = self.labelStr;
    self.labelN.textAlignment = NSTextAlignmentCenter;
    self.labelN.font = [UIFont systemFontOfSize:12 * kWidth];
    
    
    [self.btn addSubview:self.labelN];
    [_labelN release]; 
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
